<?php
class Question {

	public $id;
	public $libelle;
		
	
	
	public function __construct($id='') {
		if($id != ''){
			$this->id = $id;
			$this->load();
		}
	}

	public function load() {
		if(isset($this->id)){
			$db = Database::getInstance();
			$sql= 'SELECT idQuestion, 
                                      libelle,                                   
                                      date
                               FROM question
			       WHERE idQuestion = "'.$this->id.'"';					
						  
						  
			if ($result = $db->fetch($sql)){				
				$this->libelle = $result[0]['libelle'];					
				
				return true;
			}
			return false;	
		}
	}
	
	public function __toString(){
		return $this->libelle.' ';
	
	}
	
	
	public static function getAll() {
		
	}
	
		
	public function addQuestion($libelle){	
	/* On �chappe les information ins�r�es par l'utilisateur*/
		
		$db = Database::getInstance();
		$sql= 'INSERT INTO `question` (
		`idQuestion` ,
		`libelle` ,
                `date`
		)
		VALUES 
		(
		NULL ,
		"'.$libelle.'",		
		CURRENT_TIMESTAMP
		)';
		
		if($db->exec($sql)){
			return $db->lastInsertId();
		}
		
		return false;	
	}
	
	
}

?>